<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>商品管理</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	
	<link rel="stylesheet" type="text/css" href="css/showgoods.css">
	<script type="text/javascript">
	//分页
		function firstpage(){
			window.location.href="pageFirst11.do";
		}
		
		function lastpage(){
			window.location.href="pageLast11.do";
		}
		
		function uppage(){
			var nowPage=document.getElementById("page_value").value;
			
			window.location.href="pageUp11.do?nowPage="+nowPage;
		}
		
		function downpage(){
			var nowPage=document.getElementById("page_value").value;
			
			window.location.href="pageDown11.do?nowPage="+nowPage;
		}
	
		function yesno(){
			var c=confirm("确定删除");
			
				return c;		
		}
		function loadfirst(){
    	var req = new XMLHttpRequest();
		var first = document.getElementById("first");
		req.onreadystatechange= function(){
			if(req.readyState==4){
				var info = req.responseText;
				var infos=info.split("@@@");
				for(var i = 0;i<infos.length;i++){
					if(infos[i]!=""){
						var name = infos[i];
						var newOPtion = document.createElement("option");
						newOPtion.value=name;
						newOPtion.innerHTML=name;
						first.appendChild(newOPtion);
					}
				}
			}
		};
		req.open("post", "LoadFirst.do", true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.send();
    }
    function loadsecond(){
    	var req = new XMLHttpRequest();
		var second = document.getElementById("second");
		req.onreadystatechange= function(){
			if(req.readyState==4){
				var info = req.responseText;
				var infos=info.split("@@@");
				for(var i = 0;i<infos.length;i++){
					if(infos[i]!=""){
						var name = infos[i];
						var newOPtion = document.createElement("option");
						newOPtion.value=name;
						newOPtion.innerHTML=name;
						second.appendChild(newOPtion);
					}
				}
			}
		};
		req.open("post", "LoadSecond.do", true);
		req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		req.send();
    }
    window.onload=function(){
			loadfirst();
	}
	</script>

  </head>
  
  <body>
  	<div class="div_all">
  		<%-- <div class="div_1">
  				<div style="position: absolute;">
			<c:if test="${username1!=null}">
				<span style="color:red;">用户名: ${username1}</span>
			</c:if>
			<c:if test="${username1==null}">
				<a href="qiehuanUser.do" style="text-decoration: none;color:red;">亲，请登入</a>
			</c:if></div>
			<!-- <div class="div_menu">
				<a href="add_goods_showtype.do" class="a_menu">添加商品 </a>
  				<a href="show_goods.do" class="a_menu">查询商品 </a>
  				<a href="add_type.do" class="a_menu">类别管理 </a>
  				<a href="show_ads.do" class="a_menu">广告维护 </a>
  				<a href="zhuce.jsp" class="a_menu">注册账号 </a>
  				<a href="qiehuanUser.do" class="a_menu">切换账号 </a>
  				<a href="select_orders.do" class="a_menu">订单查询 </a>
  				<a href="go_tongji.do" class="a_menu">销售统计 </a>
			</div> -->
  			</div>
  		</div> --%>
  		
  		<div class="div_2">
	  		<div class="div_show">
	  			<!--搜索  -->
				<div class="div_sousuo">
					<form action="show_article.do" method="post">
						<!--placeholder会在输入字段为空时显示，并会在字段获得焦点时消失。-->
						<input type="text" class="input1" name="name" placeholder="文章名称"/>
						<input type="submit" class="button1" value="搜索" />
					</form>
				</div>
				<div>
					<form action="show_article.do" method="post">
						<select id="first" name="first"></select>
						<input type="submit" class="button1" value="板块搜索" />
					</form>
					
				</div>
			    <table class="table_class">
			    	<tr >
			    		<td width="200px" height="40px">文章名</td>
			    		<td width="200px" height="40px">文章作者</td>
			    		<td width="200px" height="40px">所在板块</td>
			    		<td width="200px" height="40px">文章简介</td>
			    		<td width="200px" height="40px">发表时间</td>
			    		<td width="200px" height="40px">是否上架</td>
			    	
			    	</tr>
			    	<!--显示商品详情 -->
			    	<c:forEach items="${aList}" var="Article">
				    	<tr>
				    		<td>${Article.name}</td>
				    		<td>${Article.author}</td>
				    		<td>${Article.bankuai}</td>
				    		<td>${Article.scan}</td>
				    		<td>${Article.time}</td>
				    		<td>${Article.isSj}</td>
				    		
				    		<td width="100px" height="40px"><a  href="getarticlebyid.do?id=${Article.id}" class="goods_update">更改</a><td >
				    		<td width="100px" height="40px"><a onclick="return yesno()" href="delete_article.do?id=${Article.id}" class="goods_delete">删除</a><td >
				    		<%-- <td width="100px" height="40px"><a  href="getdetail1.do?id=${Article.id}" class="goods_look">查看详情</a><td > --%>
				    	</tr>
				    	
			    	</c:forEach>
			    	
			    	
			    	<!--分页-->
			    	<tr>
			    		<td></td>
			    		<td><input type="button" value="首页" onclick="firstpage()"></td>
			    		<td></td>
			    		<td><input type="button" value="上一页" onclick="uppage()"></td>
			    		<td><input type="button" value="下一页" onclick="downpage()"></td>
			    		<td></td>
			    		<td><input type="button" value="尾页" onclick="lastpage()"></td>
			    		
			    	</tr>
			   
			    </table>
			    <input type="hidden" id="page_value" value="${page.nowpage}"/>
		    </div>
	    </div>
    </div>
  </body>
</html>
